/*
 * @Title: 商品详情  180625 新增秒杀商品详情 181111新增399大礼包
 * @Author: 姜世龙
 * @Date:   2017-12-20
 * @Last Modified by:   JSL
 * @Last Modified time: 2018-12-05 16:49:11
 */
var flag = true,
  dataInfo = new Object(),
  template = {
    loadData: function() { // template.loadData(); 初始化加载商品信息
      if (dataInfo.all.isFx == 1) { //fx
        dataInfo.goodInfoUrl = addressUrl + SERVICE.queryFxGoodsDetail; //开发环境地址
        dataInfo.goodInfoData = {
          virtualGoodsCode: dataInfo.productId,
          userId: dataInfo.userId
        };
      } else { //zy
        dataInfo.goodInfoUrl = addressTest + SERVICE.queryGoodsDetail;
        dataInfo.goodInfoData = {
          virtualGoodsCode: dataInfo.productId
        };
      };
      ajaxTemplate(dataInfo.goodInfoUrl, function(data) { //商品详情初始化 - 无需登录
        console.log('商品详情汇总');
        console.log(data);
        if (data.tag == 0) {
          var daTa = data.data.result[0];
          if (dataInfo.all.isFx == 1 && (daTa.role > 2)) {
            !!dataInfo.all.isApp ? dataInfo.all.isDz = true : '';
            dataInfo.all.priceRange = daTa.priceRange;
            dataInfo.all.priceRangeAmount = daTa.priceRangeAmount;
            dataInfo.all.inventory = daTa.inventory;
            dataInfo.all.killInventory = daTa.killInventory;
          };
          dataInfo.all.killpriceRange = daTa.killpriceRange;
          dataInfo.all.killpriceRangeAmount = daTa.killpriceRangeAmount;
          //下架跳转下架页面
          daTa.isOut == 1 ? location.href = "../html/soldOut.html" : '';
          dataInfo.all.limitNumber = daTa.limitNumber;
          dataInfo.all.secondKillPrice = daTa.secondKillPrice;
          dataInfo.all.supportCoupons = daTa.supportCoupons;
          dataInfo.all.isCoupons = daTa.isCoupons;
          dataInfo.all.freeShippingAmount = daTa.freeShippingAmount;
          dataInfo.all.shippingAmount = daTa.shippingAmount;
          dataInfo.all.sellingPointsDesc = daTa.sellingPointsDesc; // 卖点
          dataInfo.all.lowMarketPrice = daTa.lowMarketPrice; //市场价
          dataInfo.all.lowSellingPrice = daTa.lowSellingPrice; //售价
          dataInfo.all.lowVipPrice = daTa.lowVipPrice; //会员价
          dataInfo.all.imgUrl = daTa.imgUrl; //   商品图片
          dataInfo.all.goodsName = daTa.goodsName; //商品名字
          dataInfo.all.virtualGoodsCode = daTa.virtualGoodsCode; //   商品编码
          !!dataInfo.all.isApp ? template.loadDiary() : ''; //渲染推荐日记列表
          /*详情+购买须知 图片处理*/
          // daTa.detail = template.imgReduce(daTa.detail, '.jpg');  //去除图片重复压缩校验
          // daTa.detail = template.imgReduce(daTa.detail, '.png');
          daTa.instructions = template.imgReduce(daTa.instructions, '.jpg');
          daTa.instructions = template.imgReduce(daTa.instructions, '.png');
          //新增视频播放
          dataInfo.all.videoUrl = daTa.videoUrl; //   商品图片预览
          dataInfo.all.videoFristImgUrl = daTa.videoFristImgUrl; //   商品图片预览
          /*dataInfo.all.specificationChooce(false)*/
          //票选id信息
          // dataInfo.all.voteItemCode = daTa.voteItemCode; //改为从前一页面获取
          // dataInfo.all.voteActivityIssueNum = daTa.voteActivityIssueNum;//改为从前一页面获取
          //秒杀倒计时
          if (daTa.isKill == 0 || (getQueryString('isKill') == 1 && daTa.isKill == 2)) { //180829 修改秒杀状态
            dataInfo.all.msType = 'MS';
            dataInfo.all.countDown(daTa.startTime, daTa.nowTime, daTa.endTime);
          };

          setTimeout(function() {
            dataInfo.all.instructions = daTa.instructions; //   购买须知
            dataInfo.all.detail = daTa.detail; //商品详情
            dataInfo.all.datailImgs = template.getImgUrl(dataInfo.all.detail); //商品详情图片优化
            template.randomRecommendGoods();
          }, 400);
          /*详情+购买须知 图片处理*/
        } else {
          dataInfo.all.$toast(data.errMsg);
        };
      }, dataInfo.goodInfoData, {
        nologin: 1
      });
    },
    getImgUrl: function(str) { //获取商品详情图片集合 template.getImgUrl(str);
      var arr = new Array();
      str.split('src="').forEach(function(item, index) {
        index > 0 ? arr.push(item.split('"')[0] + "_600x8000.jpg") : '';
      });
      return arr;
    },
    imgReduce: function(imgData, format) { //格式前面要加.，降低容错率    template.imgReduce(imgData, format);
      var imgArr = imgData.split(format),
        imgStr = '';
      imgArr.forEach(function(item, index) {
        if (index == imgArr.length - 1 || imgArr[index].indexOf('group1/M00') < 0) {
          imgStr += imgArr[index];
        } else {
          format == '.jpg' ? imgStr += imgArr[index] + '.jpg_600x8000.jpg' : imgStr += imgArr[index] + '.png_600x8000.jpg';
        };
      });
      return imgStr;
    },
    loadDiary: function() { // template.loadDiary(); 日记加载
      ajaxTemplate(addressTest + SERVICE.queryGoodsDiary, function(data) { //获取商品关联日记 - 无需登录
        console.log(data);
        if (data.tag == 0) {
          dataInfo.all.diary = data.data.result;
        } else {
          template.hintInfo(data.errMsg);
        };
      }, {
        userId: dataInfo.userId,
        goodsCode: dataInfo.all.virtualGoodsCode,
        access_token: token,
      }, {
        nologin: 1
      });
    },
    init: function() { // template.init(); vue初始化
      dataInfo.scrollswitch = 1;
      dataInfo.switchTop = 1;
      dataInfo.productId = getQueryString('productId');
      dataInfo.userId = isApp == 1 ? getQueryString('userId') : userId;
      dataInfo.myVideo = document.getElementsByClassName('theVideo')[0];
      Vue.use(VueLazyload, {
        preLoad: 2.4,
        error: '../img/product/init.png',
        loading: '../img/product/init.png',
        attempt: 2
      });
      dataInfo.all = new Vue({
        el: ".body-product",
        data: {
          voteItemCode: getQueryString('voteItemCode'), //投票项code
          voteActivityIssueNum: getQueryString('voteItemNum'), //票选活动期数
          isPx: getQueryString('isPx'),
          ChooceSaveType: 0, //默认加入购物车保存
          isApp: isApp == 1 ? 1 : 0,
          isGift: getQueryString('isGift'), //是否是大礼包
          isFx: getQueryString('isFx'), //分销展示判断
          isDz: false, //是否分销店主 - 显示商品赚多少钱
          playVideoUrl: '../img/playVideo2.png', //暂停
          statusMs: '开始', //开始结束 切换
          limitNumber: '', //限购数量
          secondKillPrice: "", //秒杀价格
          scrollNum: 1, //当前滑动到第几页
          scrollAll: 1, //可滑动的总页数
          imgUrl: [], //滑动图片汇总
          videoUrl: '', //视频地址
          videoFristImgUrl: '', //视频首图
          dataBtn: '商品<br/>详情', //商品详情按钮
          isCoupons: "", //是否有店铺优惠券
          supportCoupons: '', //是否 0-支持，1不支持
          msType: '', //是否是秒杀 整体开关控制
          playVideo: true, //视频播放与否 false代表播放 页面预览图消失
          detail: '', //商品详情
          instructions: '', //购买须知
          backtop: false, //返回顶部按钮显隐
          freeShippingAmount: "", //满多少钱包邮
          shippingAmount: "", //邮费
          goodsName: '', //商品名称
          sellingPointsDesc: '', //商品描述
          lowSellingPrice: '',
          lowMarketPrice: '',
          lowVipPrice: '',
          priceRange: '', //价格的区间-fx
          priceRangeAmount: '', //佣金的区间-fx
          inventory: '', //分销库存
          killInventory: '', //秒杀库存
          virtualGoodsCode: '', //商品id
          hot: [], //热卖商品、推荐商品集合
          diary: [], //推荐日记
          versions: getQueryString('versions'), //版本号
          versionsCode: getQueryString('versionsCode'), //版本号
          days: '00', //秒杀倒计时
          hours: '00',
          minutes: '00',
          seconds: '00',
          queryShopCodeData: {}, //查询店主邀请码
          CartNum: 0, //购物车数量
          bottowPopup: { //底部弹框
            cartShow: false, //规格选择
            show: false, //保障说明
          },
          specificationData: { //购物车规格
            inventory: "",
            specificationList: [],
            secondActive: 100,
            specificationDetail: {}, //规格详情
            num: 1, //数量
            goodsCode: ""
          },
          isGiftVip: !getQueryString('isGiftVip') ? 0 : getQueryString('isGiftVip'),
          appInfoEnter: false,
          userName: '',
          userPhone: '',
          datailImgs: [], //商品详情图片优化
          killCode: '', //秒杀code
        },
        methods: {
          onChange: function(index) { //轮播指示回显
            this.scrollNum = index + 1;
          },
          init: function() {
            if (!!access_token && !this.isApp) { //不在app内且用户已经登录
              dataInfo.all.queryCartNum(); //购物车数量
              dataInfo.all.specificationChooce(false); //初始化查询商品规格 优化加载流程
            };
          },
          on: function() {
            downAppFun();
          },
          specificationChooce: function(tg, type, giftType) { //规格选择 type true为购物车 false为直接购买
            dataInfo.all.ChooceSaveType = type; //判断购买渠道
            if (!!access_token) { //登录验证
              ajaxTemplate(addressUrl + SERVICE.queryFxGoodsSku, function(data) { //获取商品规格 需登录
                console.log('商品规格集合');
                console.log(data);
                if (data.tag == 0) { //默认选中第一个规格
                  dataInfo.all.killCode = data.data.killCode;
                  dataInfo.all.specificationData.specificationList = data.data.result;
                  if (dataInfo.all.specificationData.specificationList[0].isKill == 0) {
                    dataInfo.all.specificationData.inventory = data.data.stock;
                  } else {
                    dataInfo.all.specificationData.inventory = dataInfo.all.specificationData.specificationList[0].inventory;
                  };
                  dataInfo.all.specificationData.num = 1
                  dataInfo.all.specificationData.specificationDetail = {
                    imgUrl: dataInfo.all.imgUrl[0],
                    inventory: data.data.stock,
                    price: data.data.priceRange,
                    specifications: "请选择规格"
                  };
                  //单规格默认选中，多规格 不选
                  if (dataInfo.all.specificationData.specificationList.length == 1 && dataInfo.all.specificationData.specificationList[0].inventory > 0) {
                    dataInfo.all.specificationData.secondActive = 0;
                    dataInfo.all.specificationData.goodsCode = dataInfo.all.specificationData.specificationList[0].goodsCode;
                    dataInfo.all.specificationData.specificationDetail = dataInfo.all.specificationData.specificationList[0];
                  } else {
                    dataInfo.all.specificationData.secondActive = 100;
                  };
                  if (dataInfo.all.specificationData.specificationList.length == giftType) { //大礼包商品数量为1直接走提交订单
                    dataInfo.all.specificationChooceSave();
                  } else if (tg) {
                    dataInfo.all.bottowPopup.cartShow = !dataInfo.all.bottowPopup.cartShow;
                  };
                } else {
                  dataInfo.all.$toast(data.errMsg);
                };
              }, {
                virtualGoodsCode: getQueryString("productId")
              });

            } else {
              jumpLogin();
            };
          },
          toNext: function() { //大礼包分享or直接购买
            if (!this.isApp) { //立即购买
              if (this.isGift == 1) { //大礼包真实姓名录入
                // this.getUserPhone();
                this.queryJudge();
              } else { //商品直接购买流程
                this.specificationChooce(true, 1, 1);
              };
            } else { //分享 app内部  app内部只有vip才能看到大礼包页 所以不必单独判断
              this.isGiftVip == 0 ? location.href = "jg://com.simeitol.www?type=inviteVipStorer" : dataInfo.all.getAppGiftPayInfo(getQueryString('goodsCode'));
            };
          },
          backAppIndex: function() { //app交互  返回上一页
            location.href = "jg://com.simeitol.www?type=backAppIndex";
          },
          blurMouse: function() { //失去光标事件
            clearInterval(dataInfo.baginStartTime); //清除计时器
            document.body.scrollTop = dataInfo.baginStartTime;
          },
          getAppGiftPayInfo: function(e) { //录入用户真实姓名 app内部只有vip才能看到大礼包页 所以不必单独判断
            dataInfo.appGiftPayInfo = e;
            this.appInfoEnter = true;
          },
          queryJudge: function() { //181207 新增 验证用户身份
            ajaxTemplate(addressCodeUrl + SERVICE.queryJudge, function(data) {
              console.log(data);
              if (data.tag == 0 && data.data.result.bindingCode == 0) { // bindingCode ==0 分销用户 、bindingCode ==1 直营用户 跳转登录
                dataInfo.all.getUserPhone();
              } else {
                jumpLogin();
              };
            }, {
              userId: userId
            });
          },
          getUserPhone: function() { //回显用户手机号
            ajaxTemplate(addressUrl + SERVICE.getGiftUserPhone, function(data) {
              console.log(data);
              if (data.tag == 0) {
                dataInfo.all.userPhone = data.data.result.phone;
                dataInfo.appGiftPayInfo = getQueryString('goodsCode'); //商品信息赋值
                dataInfo.all.getUserIdentity();
                // dataInfo.all.appInfoEnter = true; //引导用户填写手机号
              } else {
                dataInfo.all.$toast(data.errMsg);
              };
            }, {
              userId: userId
            });
          },
          getUserIdentity: function() { //判断登录人是否是店主
            ajaxTemplate(addressCodeUrl + SERVICE.fxDzPhone, function(data) {
              console.log(data);
              if (data.tag == 0) {
                data.data.result.userRole > 2 ? dataInfo.all.$toast('您已是VIP店主') : dataInfo.all.appInfoEnter = true; //引导用户填写手机号
              } else {
                dataInfo.all.$toast(data.errMsg);
              };
            }, {
              phone: dataInfo.all.userPhone,
            });
          },
          toAppGiftPay: function() { //app端大礼包 - vip仅需填写姓名 无需登录
            if (!!this.userName) {
              ajaxTemplate(addressUrl + SERVICE.fxNameSave, function(data) {
                console.log(data);
                if (data.tag == 0) {
                  dataInfo.all.appInfoEnter = false;
                  if (dataInfo.all.isApp == 0 || !isApp) { //H5购买
                    dataInfo.all.specificationChooce(true, 1, 1);
                  } else { //app购买
                    location.href = "jg://com.simeitol.www?type=toFxDLBOrders&productId=" + dataInfo.appGiftPayInfo;
                  };
                } else {
                  dataInfo.all.$toast(data.errMsg);
                };
              }, {
                userId: isApp == 1 ? getQueryString('uid_') : userId,
                realName: this.userName
              }, {
                nologin: 1
              });
            };
          },
          specificationDetail: function(index) { //规格详情
            dataInfo.all.specificationData.secondActive = index;
            dataInfo.all.specificationData.specificationDetail = dataInfo.all.specificationData.specificationList[index];
            dataInfo.all.specificationData.goodsCode = dataInfo.all.specificationData.specificationList[index].goodsCode;
          },
          specificationChooceSave: function() { //规格选择确定
            if (flag) {
              if (dataInfo.all.specificationData.specificationList.length != 1 && dataInfo.all.specificationData.secondActive == 100) {
                this.$toast('请选择规格');
              } else {
                flag = false
                if (dataInfo.all.ChooceSaveType == 0) { //加入购物车
                  dataInfo.all.$toast.loading({
                    forbidClick: true,
                    message: '数据提交中...',
                    loadingType: 'spinner',
                    duration: 0,
                  });
                  ajaxTemplate(addressUrl + SERVICE.insertCartGoods, function(data) { //加入购物车 - 需登录
                    flag = true
                    dataInfo.all.$toast.clear();
                    if (data.tag == 0) {
                      dataInfo.all.queryCartNum();
                      dataInfo.all.bottowPopup.cartShow = !dataInfo.all.bottowPopup.cartShow;
                    } else {
                      dataInfo.all.$toast(data.errMsg);
                    };
                  }, {
                    userId: dataInfo.userId,
                    num: dataInfo.all.specificationData.num,
                    goodsCode: dataInfo.all.specificationData.goodsCode
                  });
                } else { //立即购买、大礼包直接购买
                  var goodsInfo = [{
                    num: dataInfo.all.specificationData.num,
                    goodsCode: dataInfo.all.specificationData.goodsCode,
                    isKill: dataInfo.all.msType == 'MS' ? 0 : 1,
                  }];
                  dataInfo.all.msType == 'MS' ? goodsInfo[0].killCode = dataInfo.all.killCode : '';
                  console.log(goodsInfo);
                  dataInfo.all.$toast.loading({
                    forbidClick: true,
                    message: '数据提交中...',
                    loadingType: 'spinner',
                    duration: 0,
                  });
                  ajaxTemplate(addressUrl + SERVICE.outh5, function(data) { //H5购买 or 大礼包购买
                    console.log(data);
                    flag = true;
                    dataInfo.all.$toast.clear();
                    if (data.tag == 0) {
                      !dataInfo.all.isGift ? dataInfo.all.bottowPopup.cartShow = !dataInfo.all.bottowPopup.cartShow : '';
                      var result = escape(JSON.stringify(data.data.result));
                      setTimeout(function() {
                        // result 新增地址邮费 => 改为 JSON.stringify(goodsInfo)
                        window.location.href = "orderFilling.html?isGiftPacksOrder=" + dataInfo.all.isGift + "&orderData=" + JSON.stringify(goodsInfo[0]);
                      }, 500);
                    } else {
                      dataInfo.all.$toast(data.errMsg);
                    };
                  }, {
                    userId: dataInfo.userId,
                    goodsInfo: JSON.stringify(goodsInfo),
                    isGiftPacksOrder: !this.isGift ? 1 : 0 //	是否是大礼包:0-是 1-否
                  }, "bytn");

                }

              }

            } else {
              dataInfo.all.$toast("重复点击");
            }
          },
          queryCartNum: function() { //查询购物车数量 - 需登录
            ajaxTemplate(addressUrl + SERVICE.queryCartNum, function(data) {
              if (data.tag == 0) {
                dataInfo.all.CartNum = data.data.result
              } else {
                dataInfo.all.$toast(data.errMsg);
              };
            }, {
              userId: dataInfo.userId,
            });
          },
          countDown: function(startTime, nowTime, endTime) { //秒杀倒计时 ajax内第一次判断
            if (startTime > nowTime) { //秒杀未开始
              dataInfo.all.statusMs = '开始';
              this.getCountDown(startTime, nowTime, endTime);
            } else if (nowTime > startTime && endTime > nowTime) { //秒杀进行中
              dataInfo.all.statusMs = '结束';
              this.getCountDown(startTime, nowTime, endTime);
            } else { //秒杀已结束
              window.location.reload();
            };
          },
          getCountDown: function(bagin, end, stop) { //秒杀倒计时 实时数据处理
            dataInfo.baginTime = end;
            setInterval(function() {
              if (bagin > dataInfo.baginTime) { //秒杀未开始
                dataInfo.all.statusMs = '开始';
                dataInfo.baginTime += 1000;
                dataInfo.all.GetDateDiff(dataInfo.baginTime, bagin);
              } else if (dataInfo.baginTime > bagin && stop > dataInfo.baginTime) { //秒杀进行中
                dataInfo.all.statusMs = '结束';
                dataInfo.baginTime += 1000;
                dataInfo.all.GetDateDiff(dataInfo.baginTime, stop);
              } else { //秒杀已结束
                window.location.reload();
              };
            }, 1000);
          },
          GetDateDiff: function(startDate, endDate) { //秒杀倒计时 时间处理
            var date3 = endDate - startDate; //时间差的毫秒数
            //计算出相差天数
            var days = Math.floor(date3 / (24 * 3600 * 1000));
            //计算出小时数
            var leave1 = date3 % (24 * 3600 * 1000); //计算天数后剩余的毫秒数
            var hours = Math.floor(leave1 / (3600 * 1000));
            //计算相差分钟数
            var leave2 = leave1 % (3600 * 1000); //计算小时数后剩余的毫秒数
            var minutes = Math.floor(leave2 / (60 * 1000));
            //计算相差秒数
            var leave3 = leave2 % (60 * 1000); //计算分钟数后剩余的毫秒数
            var seconds = Math.round(leave3 / 1000);
            if (days < 10) {
              days = "0" + days;
            };
            if (hours < 10) {
              hours = "0" + hours;
            };
            if (minutes < 10) {
              minutes = "0" + minutes;
            };
            if (seconds < 10) {
              seconds = "0" + seconds;
            };
            this.days = days;
            this.hours = hours;
            this.minutes = minutes;
            this.seconds = seconds;
          },
          back_top: function() {
            $(".storeBody").stop().animate({
              "scrollTop": 0
            }, 500);
          },
          handleScroll: function() {
            var storeBody = document.getElementsByClassName('storeBody')[0],
              scrollTop = storeBody.pageYOffset || storeBody.scrollTop;
            if (scrollTop > 300) {
              this.backtop = true;
            } else {
              this.backtop = false;
            };
          },
          toDetails: function() { // toMall
            $(".storeBody").stop().animate({
              "scrollTop": $(".toDetails").get(0).offsetTop
            }, 400);
          },
          toCoupon: function(num) { //保障说明
            if (num == 1) { // 商品详情 跳转app 15天无理由退货地址
              !!this.isApp && !this.isGift ? location.href = "jg://com.simeitol.www?type=toSalesInfo&userId=" + dataInfo.userId + "&productId=" + this.virtualGoodsCode : !this.isGift ? dataInfo.all.bottowPopup.show = !dataInfo.all.bottowPopup.show : '';
            } else if (num == 2 && this.isCoupons && this.supportCoupons == 0) { // 商品详情 跳转app 领优惠券地址
              location.href = "jg://com.simeitol.www?type=toCoupon&userId=" + dataInfo.userId + "&productId=" + this.virtualGoodsCode;
            } else if (num == 3) { //商品票选信息跳转
              if (!!this.isApp) { //app内调用app内部跳转
                location.href = "jg://com.simeitol.www?type=toFPtVoteDetails&voteItemCode=" + this.voteItemCode;
              } else { //H5商城跳转  从更多列表页面进入详情页面时
                location.href = 'FPtVoteDetails.html?voteItemCode=' + this.voteItemCode;
              };
            };
          },
          toProduct: function(code, imgUrl, title, isSelf) { //热卖商品
            dataInfo.scrollswitch == 1 ? location.href = "../html/productDetails.html?userId=" + dataInfo.userId + "&access_token=" + access_token + "&productId=" + code + "&shareUrl=" + imgUrl + "&shareTitle=" + title + '&isFx=' + getQueryString('isFx') + "&v_=" + getQueryString('v_') + "&pt_=" + getQueryString('pt_') + "&m_=" + getQueryString('m_') + "&uid_=" + getQueryString('uid_') + "&access_token=" + getQueryString('access_token') + '&isApp=' + this.isApp : '';
          },
          toDiary: function(id, createTime, userId) { //日记详情
            location.href = "jg://com.simeitol.www?type=toDiary&id=" + id + "&createTime=" + createTime + "&userId=" + userId + "&goodsCode=" + dataInfo.all.virtualGoodsCode;
          },
          toMoreDiary: function() { //更多日记
            location.href = "jg://com.simeitol.www?type=toMoreDiary&userId=" + dataInfo.userId + "&productId=" + this.virtualGoodsCode;
          },
          playVideoNow: function() {
            this.playVideo = false;
            dataInfo.myVideo = document.getElementsByClassName('theVideo')[0]; //二次定义 不然会报错
            dataInfo.progressWrap = document.getElementsByClassName('progressWrap')[0];
            dataInfo.playProgress = document.getElementsByClassName('playProgress')[0];
            dataInfo.progressFlag = setInterval(function() {
              var percent = dataInfo.myVideo.currentTime / dataInfo.myVideo.duration;
              dataInfo.playProgress.style.width = percent * (dataInfo.progressWrap.offsetWidth) + "px";
            }, 60);
            dataInfo.myVideo.addEventListener('ended', function() {
              dataInfo.all.playVideo = true;
              dataInfo.playProgress.style.width = 0;
              clearInterval(dataInfo.progressFlag);
            }, false);
            dataInfo.myVideo.play();
          },
          stopVideoNow: function() {
            dataInfo.myVideo = document.getElementsByClassName('theVideo')[0]; //二次定义 不然会报错
            if (dataInfo.myVideo.paused) {
              this.playVideoUrl = '../img/playVideo2.png';
              this.playVideoNow();
            } else {
              this.playVideoUrl = '../img/playVideo.png';
              dataInfo.myVideo.pause();
              clearInterval(dataInfo.progressFlag);
            }
          },
        },
        mounted: function() {
          /*返回顶部监控*/
          document.getElementsByClassName('storeBody')[0].addEventListener('scroll', this.handleScroll);
        },
        computed: {
          diaryWidth: function() {
            return this.diary.length * 155 + 5;
          },
          android: function() {
            if (browser.versions.android == true) {
              return false;
            } else {
              return true;
            };
          }
        }
      });
      dataInfo.all.init()
      template.loadData();
    },
    hintInfo: function(info) { // template.hintInfo();
      $(".hintInfo").html(info).show();
      setTimeout(function() {
        $(".hintInfo").fadeOut();
      }, 2500);
    },
    randomRecommendGoods: function() { //随机推荐商品 template.randomRecommendGoods();
      ajaxTemplate(addressUrl + SERVICE.queryFxGoodsRecommend, function(data) { //获取推荐商品 - 无token 无登录
        console.log('推荐商品');
        console.log(data);
        var daTa = data.data.result;
        if (data.tag == 0) {
          //  随机推荐商品
          dataInfo.all.hot = new Array();
          daTa.forEach(function(item, index) {
            if (item.isKill !== 0) {
              dataInfo.all.hot.push(item);
            };
          });
          setTimeout(function() {
            var tid = "index" + (daTa.length - 1);
            $('#' + tid).ready(function() {
              $(".loadImgBox").addClass("rgba").hide();
            });
          }, 300);
        } else {
          template.hintInfo(data.errMsg);
        };
      }, {
        virtualGoodsCode: dataInfo.productId
      }, {
        nologin: 1
      });
    },
    getShareInfo: function() { // template.getShareInfo();
      var getShareInfo = "productId=" + dataInfo.productId + "&shareUrl=" + dataInfo.all.imgUrl[0] + "&shareTitle=" + dataInfo.all.goodsName;
      return getShareInfo;
    },
    toMall: function() { // template.toMall();  toDetails
      // dataInfo.scrollswitch = 2;
      // dataInfo.switchTop == 1 ? dataInfo.switchTop = $(".toMall").get(0).offsetTop : '';
      $('#details').css({
        'height': $('#details').height(),
        'overflow': 'hidden'
      });

      $(".storeBody").stop().animate({
        "scrollTop": $(".toMall").get(0).offsetTop
      }, 300, function() {
        // dataInfo.scrollswitch = 1;
        $('#details').css({
          'height': 'auto',
          'overflow': 'hidden'
        });
      });

    },
    iosInfoHide: function() { //ios 弹窗隐藏 template.iosInfoHide();
      dataInfo.all.appInfoEnter = false;
    },
  };
template.init();
